POV-Ray : Newsgroups : povray.general : simulating lens distortion with normal and function in 3.5 : Re: simulating lens distortion with normal and function in 3.5 Server Time
6 Aug 2024 16:59:28 EDT (-0400)
  Re: simulating lens distortion with normal and function in 3.5  
From: Dennis Miller
Date: 24 Feb 2002 15:04:47
Message: <3c79475f$1@news.povray.org>
This code shows up completely black under 3.5....
I don't have the technical answers, but I have used normals in camera
statements for great effect; the result is sort of like a 3D filter on the
camera lens. It changes the surface properties of the lens, in essence.
Here's a little example: nothing but a sky sphere in here. Animation
possibilities are endless!

global_settings { assumed_gamma 2.2 }
#include "colors.inc"

camera {
 location <-5, 6,-58>
 look_at < 0, 5.5, 0>
 angle 35
      normal {
        gradient <1,0,1>
        normal_map {
          [.1  agate  30]
          [.3  marble 50 ]
          [ .6  wood  70 ]
          [ .9 crackle 50 ]  } } }

light_source { <10,10,-30> rgb 1.5 }
 sky_sphere
{  pigment
  {gradient y  color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }   } }

Best,
D.

"Bill Brehm" <bbr### [at] netzeronet> wrote in message
news:3c78c415$1@news.povray.org...
> Hi,
>
> I've asked before about simulating lens distortion. I got some helpful
> pointers, but I'm stuck again.
>
> A mathematician working at another company came up with the following
> additions to my camera definition and sent it to me. But I cannot reach
him
> now, so I'm hoping someone here can help me understand.
>
> The distortion has the correct form, i.e., a square is distorted to the
> correct shape. But the image is also magnified and I need to control that
> too. Even when I set the factors to zero, there is magnification.
>
> So my questions are:
>
> 1. What does lens_dist() return? A float? A vector? I think it's returning
a
> single float value based on the X, Y coordinates passed in.
> 2. What is the Z parameter there for? Is it needed for the normal?
> 3. How exactly does a normal work when applied to a camera to distort the
> image? What is a normal? Is it a function or pattern that has one value
for
> each X, Y coordinate? How does that bend the ray? Is there any diagram
that
> shows how it works? I would think that a normal would need two values at
> each coordinate, so it knows how much and in which direction to bend the
> ray.
>
> Thanks,
>
> Bill
>
> PS: I have tried to find this info in the help, but couldn't.
>
>
> // lens distortion model
> // i' = i + a * i * sqrt(i^2 + j^2) + b * i^3 * sqrt(i^2 + j^2)
> // j' = j + a * j * sqrt(i^2 + j^2) + b * j^3 * sqrt(i^2 + j^2)
>
> // lens distortion implementation
> #declare lens_dist = function(x, y, z, a, b) {
>    (x + a * x * sqrt(x*x + y*y) + b * x^3 * sqrt(x*x + y*y) ) ^ 2 +
>    (y + a * y * sqrt(x*x + y*y) + b * y^3 * sqrt(x*x + y*y) ) ^ 2
> }
>
> #declare a_factor = 0.65;
> #declare b_factor = 0.1;
>
> #declare HFOV = 5.00;
> #declare VFOV = HFOV * 3 / 4;
>
> #declare cameraheight = 10.000;
>
> camera {
>   orthographic
>   location <0, 0, 0>
>   right <HFOV, 0, 0>
>   up <0, VFOV, 0>
>   sky <0, 1, 0>
>   direction <0, 0, cameraheight>
>   look_at <0, 0, 1>
>   translate <0, 0, -cameraheight>
>
>   normal{function {lens_dist(x, y, z, a_factor, b_factor)} }
> }
>
> #local mx = 9;
> #local my = 7;
> #local ix = 0;
> #while(ix < mx)
>   #local iy = 0;
>   #while(iy < my)
>     cylinder {
>       <0,0,0>, <0,0,0.010>, 0.25
>       pigment {color rgb <0, 0, 0>}
>       translate  <(ix - ((mx - 1) / 2))* 0.8, (iy - ((my - 1) / 2))* 0.8,
0>
>     }
>     #local iy = iy + 1;
>   #end
>   #local ix = ix + 1;
> #end
>
>
>
>
>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.